package com.lins.storedisk.common;

import lombok.Data;

/**
 * @Author linshuo
 * @Date 2023/8/15 13:55
 */
@Data
public class APIException extends RuntimeException{
    private int code;
    private String msg;

    public APIException() {
    }

    /**
     * 单参构造
     * @Author: linshuo
     * @Date: 2023/9/5 14:58
     * @Param:   hint 状态提示语
     * @return: null
     * 默认异常使用APP_ERROR状态码
     **/
    public APIException(String hint) {
        super(AppCode.APP_ERROR.getMsg()+hint);
        this.code = AppCode.APP_ERROR.getCode();
        this.msg = AppCode.APP_ERROR.getMsg();
    }

    /**
     * 枚举构造
     * @Author: linshuo
     * @Date: 2023/9/5 14:58
     * @Param:   appCode
     * @param hint 提示语
     * @return: null
     **/
    public APIException(AppCode appCode, String hint) {
        //用户设置抛出错误详情，例如：当前价格-5，小于0
        super(appCode.getMsg()+","+hint);
        this.code = appCode.getCode();
        this.msg = appCode.getMsg();
    }
}
